import {
  exportWz, dcexportWj, dcexportRg, dcexport, UpDownData, fakeAnswerRelevanceknowledgeData,
  linkBoxJson, unknownQuestionsList, ignoreUnknownQuestion, ignoreUnknownQuestions, toChatContextJson,
  unresolvedQuestionsJson, ignoreUnresolvedQuestion, ignoreUnresolvedQuestions, askHumanRecordsJson,
  ignoreHumanRecord, ignoreHumanRecordBatch, recoveryUnknownQuestions, relationWaitLearnQa,
  gptQuestionsJson, ignoreGptQuestion, ignoreGptQuestions, docQuestionsJson, ignoreDocQuestion, ignoreDocQuestions,
} from '@/services/capacityStudy';

export default {
  namespace: 'waitingLearningIssue',

  state: {

  },
  effects: { // 未知问题 列表

    *fetch({ payload, callback }, { call, put }) {
      const response = yield call(unknownQuestionsList, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *exportWz({ payload, callback }, { call, put }) {
      const response = yield call(exportWz, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *dcexportRg({ payload, callback }, { call, put }) {
      const response = yield call(dcexportRg, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *dcexportWj({ payload, callback }, { call, put }) {
      const response = yield call(dcexportWj, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchb({ payload, callback }, { call, put }) { // 未知问题 忽略/恢复
      const response = yield call(ignoreUnknownQuestion, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchc({ payload, callback }, { call, put }) { // 未知问题 批量忽略/恢复
      const response = yield call(ignoreUnknownQuestions, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchd({ payload, callback }, { call, put }) { // 未知问题/未解决问题/转人工问题 聊天上下文
      const response = yield call(toChatContextJson, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetche({ payload, callback }, { call, put }) { // 未解决问题 列表
      const response = yield call(unresolvedQuestionsJson, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchf({ payload, callback }, { call, put }) { // 未解决问题 忽略/恢复linkBoxJson
      const response = yield call(ignoreUnresolvedQuestion, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchh({ payload, callback }, { call, put }) { // 未解决问题 批量忽略/恢复
      const response = yield call(ignoreUnresolvedQuestions, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchr({ payload, callback }, { call, put }) { // 转人工问题 列表
      const response = yield call(askHumanRecordsJson, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchj({ payload, callback }, { call, put }) { // 转人工问题 忽略/恢复
      const response = yield call(ignoreHumanRecord, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchk({ payload, callback }, { call, put }) { // 转人工问题 批量忽略/恢复
      const response = yield call(ignoreHumanRecordBatch, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchg({ payload, callback }, { call, put }) { // 未解决问题 忽略/恢复linkBoxJson
      const response = yield call(UpDownData, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchz({ payload, callback }, { call, put }) { // 未解决问题 忽略/恢复
      const response = yield call(relationWaitLearnQa, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchy({ payload, callback }, { call, put }) {
      const response = yield call(fakeAnswerRelevanceknowledgeData, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchMl({ payload, callback }, { call, put }) { // 模型生成 列表
      const response = yield call(gptQuestionsJson, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchMm({ payload, callback }, { call, put }) { // 模型生成 忽略/恢复linkBoxJson
      const response = yield call(ignoreGptQuestion, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchMn({ payload, callback }, { call, put }) { // 模型生成 批量忽略/恢复
      const response = yield call(ignoreGptQuestions, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchFl({ payload, callback }, { call, put }) { // 文档问答 列表
      const response = yield call(docQuestionsJson, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchFm({ payload, callback }, { call, put }) { // 文档问答 忽略/恢复linkBoxJson
      const response = yield call(ignoreDocQuestion, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchFn({ payload, callback }, { call, put }) { // 文档问答 批量忽略/恢复
      const response = yield call(ignoreDocQuestions, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *dcexport({ payload, callback }, { call, put }) {
      const response = yield call(dcexport, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *recovery({ payload, callback }, { call, put }) { // 未知问题 批量忽略/恢复
      const response = yield call(recoveryUnknownQuestions, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },

  },


  reducers: {
    save(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
    clear() {
      return {

      };
    },
  },
};
